import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../l10n/app_localizations.dart';
import '../controllers/main_controller.dart';

class BottomNavigation extends StatelessWidget {
  const BottomNavigation({super.key});

  @override
  Widget build(BuildContext context) {
    final l10n = AppLocalizations.of(context);
    final MainController mainController = Get.find();

    final navigationItems = [
      {'icon': Icons.home, 'label': l10n.home},
      {'icon': Icons.description, 'label': l10n.contract},
      {'icon': Icons.science, 'label': l10n.fission},
      {'icon': Icons.account_balance_wallet, 'label': l10n.wallet},
      {'icon': Icons.settings, 'label': l10n.settings},
    ];

    return Container(
      decoration: BoxDecoration(
        color: const Color(0x800A0E27),
        border: Border(
          top: BorderSide(
            color: const Color(0xFF00FFFF).withOpacity(0.3),
            width: 1,
          ),
        ),
      ),
      child: SafeArea(
        top: false,
        child: Container(
          height: 70,
          padding: const EdgeInsets.symmetric(horizontal: 8),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children:
                navigationItems.asMap().entries.map((entry) {
                  final index = entry.key;
                  final item = entry.value;

                  return Expanded(
                    child: Obx(() {
                      final isSelected =
                          index == mainController.currentIndex.value;
                      return InkWell(
                        onTap: () {
                          mainController.changeBottomNav(index);
                        },
                        borderRadius: BorderRadius.circular(8),
                        child: Container(
                          padding: const EdgeInsets.symmetric(vertical: 8),
                          child: Column(
                            mainAxisSize: MainAxisSize.min,
                            children: [
                              Icon(
                                item['icon'] as IconData,
                                color:
                                    isSelected
                                        ? const Color(0xFF00FFFF)
                                        : Colors.white70,
                                size: 24,
                              ),
                              const SizedBox(height: 4),
                              Text(
                                item['label'] as String,
                                style: TextStyle(
                                  color:
                                      isSelected
                                          ? const Color(0xFF00FFFF)
                                          : Colors.white70,
                                  fontSize: 12,
                                  fontWeight:
                                      isSelected
                                          ? FontWeight.w600
                                          : FontWeight.normal,
                                ),
                              ),
                            ],
                          ),
                        ),
                      );
                    }),
                  );
                }).toList(),
          ),
        ),
      ),
    );
  }
}
